package com.reger.easemob.api;

import java.io.IOException;

import com.reger.easemob.api.impl.Api;
import com.reger.easemob.api.impl.Call_;
import com.reger.easemob.api.impl.TokenApi_;
import com.reger.easemob.model.Token;
import com.reger.easemob.model.TokenClient;

import retrofit2.Call;
import retrofit2.Retrofit;

public class TokenApi  extends Api{
	private TokenApi_ tokenApi;

	public TokenApi(Retrofit retrofit) {
		this.tokenApi =  retrofit.create(TokenApi_.class);
	}
	
	private Call<Token> _token(String clientId, String clientSecret) {
		return tokenApi.token( new TokenClient(clientId, clientSecret));
	}
	
	public Token token(String clientId, String clientSecret) throws IOException {
		return super.call(this._token(clientId, clientSecret));
	}

	public void asyncToken(String clientId, String clientSecret, Call_<Token> succees, Call_<Throwable> failure) {
		super.asyncCall(this._token(clientId, clientSecret), succees, failure);
	}
}
